package com.cyandpos.pad.sale.adapter;

import android.app.Activity;
import androidx.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cyandpos.pad.R;
import com.cyandpos.pad.posdata.PromationoodInfo;
import com.cyandpos.pad.utils.MoneyUtils;

import java.util.List;

/**
 * 默认商品适配器
 */
public class ExchangeGoodBillInfoListAdapter extends BaseQuickAdapter<PromationoodInfo,BaseViewHolder> {
    private Activity activity;
    private TextView etCount;
    private boolean isExchangeGoods = false;
    public ExchangeGoodBillInfoListAdapter(int layoutResId, @Nullable List<PromationoodInfo> data, Activity activity) {
        super(layoutResId, data);
        this.activity = activity;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, PromationoodInfo promationoodInfo) {
        LinearLayout hg = baseViewHolder.getView(R.id.ll_giftgoods_item);
        LinearLayout ll_mz = baseViewHolder.getView(R.id.ll_mz);
        if (isExchangeGoods){
            hg.setVisibility(View.VISIBLE);
            ll_mz.setVisibility(View.GONE);
            TextView good_xh = baseViewHolder.getView(R.id.good_xh);
            TextView good_name = baseViewHolder.getView(R.id.good_name);
            TextView good_price = baseViewHolder.getView(R.id.good_price);
            TextView khsl = baseViewHolder.getView(R.id.khsl);
            TextView hgcount = baseViewHolder.getView(R.id.hgcount);
            good_xh.setText(baseViewHolder.getLayoutPosition() +1 +  "");
            good_name.setText(promationoodInfo.getName());
            good_price.setText(promationoodInfo.getPromotionPrice());
            khsl.setText(promationoodInfo.getMaxSaleCount());
            hgcount.setText(promationoodInfo.getSaleCount());

        }else {
            hg.setVisibility(View.GONE);
            ll_mz.setVisibility(View.VISIBLE);
            TextView good_mz_xh = baseViewHolder.getView(R.id.good_mz_xh);
            TextView tvCode = baseViewHolder.getView(R.id.tv_defaultgoods_code);
            TextView mzPrice = baseViewHolder.getView(R.id.good_mz_price);
            etCount = baseViewHolder.getView(R.id.et_defaultgoods_count);
            good_mz_xh.setText(baseViewHolder.getLayoutPosition()+ 1 + "");
            tvCode.setText(promationoodInfo.getBarcode() + "【" + promationoodInfo.getName() + "】");
            mzPrice.setText(promationoodInfo.getCompensationAmount());
            etCount.setText(promationoodInfo.getSaleCount());
        }
    }

    /**
     *
     * @param isExchangeGoods 换购
     */
    public void setisExchangeGoods(boolean isExchangeGoods){
        this.isExchangeGoods = isExchangeGoods;
    }

}
